'use strict';

const Koa = require('koa');
const router = require('koa-router')();
const bodyParser = require('koa-bodyparser');

const app = new Koa();

app.use(async (ctx, next) => {
    console.log(`${ctx.request.method} : ${ctx.request.url}`)
    await next();
})

router.get('/hello/:name', async (ctx, next) => {
    let name = ctx.params.name;
    ctx.response.body = `hello, ${name}`;
})

router.get('/', async (ctx, next) => {
    ctx.response.body = 'Index'
})

app.use(bodyParser());

app.use(router.routes());

app.listen(3333);
console.log('app started at port 3333 ...');